﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 第二次作业.entity
{
    internal class Account
    {
        public string accountName { get; set; }
        public string accountPassword { get; set; }
        public double balance { get; set; }
        public Account(string accountName, string accountPassword)
        {
            this.accountName = accountName;
            this.accountPassword = accountPassword;
            this.balance = 0;
        }

        public double deposit(double amount)
        {
            this.balance += amount;
            return this.balance;
        }

        public virtual void withdraw(double amount)
        {
            if (amount > this.balance)
            {
                throw new InvalidOperationException("余额不足！");
            }

            balance -= amount;
        }
    }
}
